#include <cstdio>
#include <cstdlib>
#include "gtest/gtest.h"
#include "CPPTemplate.h"

using namespace std;
template <typename T>
const T& findMax(const vector<T> &a)
{
	int maxIndex = 0;

	for (int i = 1; i < a.size();i++)
	{
		if (a[maxIndex] < a[i])
		{
			maxIndex = i;
		}
	}
	return a[maxIndex];
};

template <typename T, typename C>
const T& findStringMax(const vector<T> &a, C cmp )
{
	int maxIndex = 0;

	for (int i = 1; i < a.size();i++)
	{
		if (cmp.isLessThan(a[maxIndex],a[i]))
		{
			maxIndex = i;
		}
	}
	return a[maxIndex];
};

class CaseInsentiveCompare
{
public:
	bool isLessThan(const string & lhs, const string &rhs ) const
	{
		return stricmp(lhs.c_str(), rhs.c_str());
	}
};

TEST(CPPTemplateTest,CPPTemplateTest )
{
	vector<Employee> v(3);
	v[0].setValue("Geroge Bush", 400000.00);
	v[1].setValue("Bill Gates", 20000000000.00);
	v[2].setValue("Dr. Phil", 1300000);
	cout<<findMax(v)<<endl;
	
}

TEST(CPPTemplateTest,CPPTemplateTest2 )
{
	vector<string> v(3);
	v[0] = "Geroge Bush";
	v[1] = "Bill Gates";
	v[2] ="Dr. Phil";
	cout<<findStringMax(v,CaseInsentiveCompare())<<endl;

}
